<?php
class ClsNaanalEMail
{
    private $arrTo=array();
    private $arrFrom=array();
    private $arrCC=array();
    private $arrBCC=array();
    private $subject="";
    private $message="";
    private $isHtmlEmail=true;

    public function __construct($subject,$message) 
    {
        $this->subject=$subject;
        $this->message=$message;
    }
    public function addFrom($from,$name=false)
    {
        $this->arrFrom["email"]=$from;
        $this->arrFrom["name"]=$name;
    }
    public function addTo($email,$name=false)
    {
        $count=count($this->arrTo);
        $this->arrTo[$count]["email"]=$email;
        $this->arrTo[$count]["name"]=$name;
    }
    public function addCC($email,$name=false)
    {
        $count=count($this->arrCC);
        $this->arrCC[$count]["email"]=$email;
        $this->arrCC[$count]["name"]=$name;
    }
    public function addBCC($email,$name=false)
    {
        $count=count($this->arrBCC);
        $this->arrBCC[$count]["email"]=$email;
        $this->arrBCC[$count]["name"]=$name;
    }
    public function isHtmlEmail($isHtml)
    {
        $this->isHtmlEmail=$isHtml;
    }
    private function buildHeader()
    {
        $headers = "From: " . strip_tags($this->arrFrom["email"]) . "\r\n";
        $headers .= "Reply-To: ". strip_tags($this->arrFrom["email"]) . "\r\n";
        if($this->arrCC)
        {
            foreach($this->arrCC as $cc)
            {
                $headers .= "CC: {$cc["email"]}\r\n";
            }
        }
        $headers .= "MIME-Version: 1.0\r\n";
        if($this->isHtmlEmail)
        {
            $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        }
        else
        {
            
        }
        return $headers;
    }
    public function send()
    {
        $success=mail($this->arrTo[0]["email"], $this->subject, $this->message, $this->buildHeader());
        return $success;
    }
}
?>